{% extends 'rango/base.html' %}

{% block title %}{{ category.name }}{% endblock %}

{% block body_block %}
{% if category %}
<div class="hero-unit">
    <h1>{{ category.name }}</h1>
    <p>
        <b id="like_count">{{ category.likes }}</b> people like this category
        {% if user.is_authenticated %}
            <button id ="likes" data-catid="{{category.id}}" class="btn btn-mini btn-primary" type="button">Like</button>
        {% endif %}
    </p>
    {% if pages %}
    <ul>
        {% for page in pages %}
        <li>
            <a href="/rango/goto/?page_id={{page.id}}">{{ page.title }}</a>
            {% if page.views >= 1 %}
                - ({{ page.views }} views)
            {% endif %}
        </li>
        {% endfor %}
    </ul>
    {% else %}
        <strong>No pages currently in category.</strong>
    {% endif %}

{% else %}
    <strong style="color: red">Category not available</strong>
{% endif %}
<a href="/rango/category/{{category.id}}/add_page/">Add a Page</a>
</div>
<hr/>

<div class="container-fluid">
    <p><strong>Search for a page.</strong></p>
    <form class="span8 form-search" id="search_form" method="post" action="/rango/category/{{category.id}}/">
        {% csrf_token %}
        <input type="text" class="input-long search-query"  name="query" value="{{ category_name }}" id="query" />
        <button type="submit" class="btn btn-success" name="submit" value="Search">Search</button>
    </form>
</div>
<div class="container-fluid">
    {% if result_list %}
    <ol>
        {% for result in result_list %}
        <li>
            <strong><a href="{{ result.link }}">{{ result.title }}</a></strong><br />
            <p>{{ result.summary }}</p>
        </li>
        {% endfor %}
    </ol>
    {% else %}
    <br/>
    <p>No results found</p>
    {% endif %}
</div>
{% endblock %}
